import table from '@/components/dt/table/render.js'
import Opt from '@/components/dt/info/Opt.js'
import CustomerMgr from '@/biz/customer/customerOpt.js'
let _this = null;

class leaveCaseColumns extends Opt {
  constructor(vm) {
    super()
    _this = vm
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [
    {
      type: 'checkbox',
      width: 40,
      align: 'center',
      fixed: 'left',
    },
    {
      field: 'customerName',
      title: '客户姓名',
      minWidth: 140,
      fixed: 'left',
      header: {
        filter: {
          title: '客户姓名',
          key: 'name',
          placeholder: '请输入客户姓名',
          input: {}
        }
      },
      slots: {
        default: (params, h) => {
          return [h(
            'div', {},
            [
              h('Tooltip', {
                  props: {
                    placement: 'top-start',
                    content: '该客户已设置“锁定”。“锁定”后，该客户将在在日报首页“重点客户”模块中优先显示',
                    transfer: true,
                    trigger: 'hover',
                    offset: '-13',
                    theme: 'dark'
                  },
                  style: {}
                },
                [h('Icon', {
                  props: {
                    type: params.row.hasLock ? 'md-lock' : '',
                    size: '20',
                  },
                  style: {
                    marginRight: '4px',
                    color: '#2d8cf0',
                    cursor: 'pointer'
                  }
                })]
              ),
              h('span', params.row.customerName)
            ]
          )]
        }
      }
    },
    {
      field: 'customerPhone',
      minWidth: 130,
      header: {
        filter: {
          title: '手机号码',
          key: 'phone',
          placeholder: '请输入手机号码',
          input: {}
        }
      }
    },
    {
      field: 'userName',
      minWidth: 120,
      header: {
        filter: {
          title: '归属顾问',
          key: 'userIds',
          placeholder: '请选择归属顾问',
          load: (o) => {
            o.select.options = CustomerMgr.consultants()
          },
          select: {
            options: [],
            multiple: true,
            filterable: true,
            remote: (key) => {
              return CustomerMgr.getConsultant(key)
            }
          }
        }
      },
    },
    {
      field: 'statusName',
      minWidth: 120,
      header: {
        filter: {
          title: '客户进度',
          key: 'status',
          placeholder: '请选择客户进度',
          load: (o) => {
            o.select.options = CustomerMgr.status()
          },
          select: {
            options: [],
            multiple: true,
            filterable: true,
          }
        }
      }
    },
    {
      field: 'channelName',
      minWidth: 140,
      header: {
        filter: {
          title: '来源渠道',
          key: 'channelSource',
          placeholder: '请选择来源渠道',
          load: (o) => {
            o.select.options = CustomerMgr.channelSource()
          },
          select: {
            options: [],
            multiple: true,
            filterable: true,
          }
        }
      }
    },
    {
      field: 'intentionLevelName',
      minWidth: 120,
      header: {
        filter: {
          title: '意向等级',
          key: 'intentionLevel',
          placeholder: '请选择意向等级',
          load: (o) => {
            o.select.options = CustomerMgr.intentionLevel()
          },
          select: {
            options: [],
            multiple: true,
            filterable: true,
          }
        }
      }
    },
    {
      title: '客户特征',
      field: 'customerFeature',
      minWidth: 220,
    },
    {
      title: '操作',
      field: 'operation',
      width: 180,
      align: 'center',
      fixed: 'right',
      slots: {
        default: (params, h) => {
          let btns = []
          btns.push({
            title: '查看详情',
            event: 'checkUser',
            data: params.row
          })
          // if(){

          // }
          btns.push({
            title: _this.unlocking('0102030400') && params.row.hasSelected ?
              !params.row.hasLock ? '首页锁定' : '取消锁定' : '',
            event: 'lockUser',
            data: params.row
          })
          return table.cell.btns(_this, h, btns)
        }
      }
    }]
  }

}


export default leaveCaseColumns